<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<%@ page import="forum.*"%>

<%
	String path = request.getContextPath();
	String basePath = "http://" + request.getServerName() + ":"
			+ request.getServerPort() + path + "/";
	Post p = (Post)request.getAttribute("post");
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
	var int = self.setInterval("checkNotifications()", 10000);

	function checkNotifications() {
		check();
	}
	
	function check(){
		var xmlhttp;
		if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp = new XMLHttpRequest();
		} else {// code for IE6, IE5
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.open("GET", "viewPostsProcessor?do=check", true);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
				if (xmlhttp.status == 200) {
					var friend = xmlhttp.responseXML.getElementsByTagName("response")[0].getElementsByTagName("friend")[0].firstChild.data;
					if (friend == "y")
						alert("Your friend added post");
					var author = xmlhttp.responseXML.getElementsByTagName("response")[0].getElementsByTagName("author")[0].firstChild.data;
					if (author == "y")
						alert("Post added to your thread");
				} else
					alert("Error\n" + xmlhttp.status + ":" + xmlhttp.statusText);
			}
		};
		xmlhttp.send(null);
	}
	
</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<base href="<%=basePath%>">

<title>Edit post</title>
</head>
<body background="background.jpg" bgcolor="AliceBlue" link="Navy" text="Navy" >
<font face="COMIC SANS MS" >
<h1 align="center">
		<font size="10"  color="FloralWhite">Edit Post</font>
</h1>
	<form name="editingPost" action="viewPostsProcessor" method="post">
		<table border="1" align="center" width=30% height=150 >
			<tbody>
				<tr>
					<td><font size="5" ><b>Subject:</b>
					</font></td>
				</tr>
				<tr>
					<td><input type="text" name="subject" disabled="disabled" value="<%=p.getSubject()%>">
					</td>
				</tr>
				<tr>
					<td><font size="5" ><b>Content:</b>
					</font></td>
				</tr>
				<tr>
					<td><textarea name="content" cols="40" rows="10"><%=p.getContent()%></textarea>
					</td>
				</tr>
				<tr>
					<td colspan="2" align="center"><input type="submit" name="btnEdit" value="edit">
					</td>
				</tr>
			</tbody>
		</table>
		<input type="hidden" name="id" value="<%=p.getID()%>">
		<input type="hidden" name="action" value="edit">
	</form>
	<br>
	<p align="center">	
	<a size=5 href="logout">logout</a>
	</p>
	</font>
</body>
</html>